package com.cxx.controller;

import com.cxx.log.Log;
import com.cxx.pojo.Result;
import com.cxx.service.ApproveService;
import com.cxx.utils.JwtUtils;
import io.jsonwebtoken.Claims;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/person-web/api/*")
public class ApproveController {
    @Autowired
    private ApproveService approveService;
    @Autowired
    private JwtUtils jwtUtils;
    @GetMapping("/approveNum")
    @Log
    public Result approveNum(){
        return Result.sucess(approveService.approveNum());
    }
    @GetMapping("/waitApprove")
    @Log
    public Result waitApprove(){
        return Result.sucess(approveService.waitApprove());
    }
    @GetMapping("approve")
    @Log
    public Result approve(String userName){
        return Result.sucess(approveService.approve(userName));
    }
    @GetMapping("/messageNum")
    @Log
    public Result messageNum(String token){
        Claims claims=jwtUtils.parseJwt(token);
        String account= (String) claims.get("name");
        return Result.sucess(approveService.messageNum(account));
    }
}
